Skip to content

feat(sdk): add random and uuid4 in workflow context#1412

Merged
chris-olszewski merged 6 commits into
mainfrom
olszewski/feat_random_utils
Jul 22, 2026
Merged

feat(sdk): add random and uuid4 in workflow context#1412
chris-olszewski merged 6 commits into
mainfrom
olszewski/feat_random_utils

Conversation

@chris-olszewski

Copy link
Copy Markdown
Member

What was changed

  • Add WorkflowContext::random and uuid4 for use in workflows
  • Add WorkflowRandomValue as our trait to allow generating different number types. Used to avoid exposing underlying rand trait.
  • Remove WorkflowContext::random_seed()
  • Make specifying child workflow optional, if omitted or empty use uuid4 to generate one

Why?

SDK parity

Checklist

  1. Closes [Feature Request] Provide random utilities #1385

  2. How was this tested:
    Various unit tests

  3. Any docs updates needed?
    N/A

@chris-olszewski
chris-olszewski marked this pull request as ready for review July 17, 2026 13:43
@chris-olszewski
chris-olszewski requested a review from a team as a code owner July 17, 2026 13:43
(),
ChildWorkflowOptions {
workflow_id: "abandoned-child".to_owned(),
workflow_id: Some("abandoned-child".to_owned()),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me kinda sad. We probably need to convert ChildWorkflowOptions into a builder?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, realized it wasn't marked as #[non_exhaustive] either which needed to be addressed before GA. Added a ChildWorkflowOptions::workflow_id constructor for the common case where only workflow id needs to get set.

<T as private::Sealed>::sample(random)
}

fn uuid4(&self) -> String {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not have a dep already that can do this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uuid was already in temporalio-sdk, but not in temporalio-workflow. Pulled it down.

@chris-olszewski
chris-olszewski force-pushed the olszewski/feat_random_utils branch from 37533a2 to 98c81e6 Compare July 21, 2026 16:11
@chris-olszewski
chris-olszewski merged commit 71f4605 into main Jul 22, 2026
22 checks passed
@chris-olszewski
chris-olszewski deleted the olszewski/feat_random_utils branch July 22, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Provide random utilities

2 participants